import newRequest from '@/utils/newRequest'
import request from '@/utils/request'
import { mergeParams } from '@/utils'

export function getDeptList(query) {
  return request({
    url: '/api/v1/deptList',
    method: 'get',
    params: query
  })
}
// 部门列表
export function getNewDeptList(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doQueryPage',
    method: 'post',
    // params: query
    data
  })
}

export function getNewDeptInfo(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/MTSaas/xjsTech/doDeptInfo',
    method: 'post',
    // params: query
    data
  })
}

// 部门结构
export function doQueryStructure(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doQueryStructure',
    method: 'get',
    params: query
    // data,
  })
}

// 新增部门
export function doSave(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doSave',
    method: 'post',
    // params: query
    data
  })
}

// 修改部门
export function doUpdate(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doUpdate',
    method: 'PUT',
    // params: query
    data
  })
}

export function getOrdinaryDeptList(params) {
  return request({
    url: '/api/v1/ordinaryDeptList',
    method: 'get',
    params
  })
}

export function bqDeptList(params) {
  return request({
    url: '/api/v1/bqDeptList',
    method: 'get',
    params
  })
}

// 查询部门详细
export function getDept(deptId) {
  return request({
    url: '/api/v1/dept/' + deptId,
    method: 'get'
  })
}

// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: '/api/v1/deptTree',
    method: 'get'
  })
}

// 查询部门下拉树结构
export function newTreeselect(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doQueryStructure',
    method: 'post',
    // params: query
    data
  })
}

export function newGetUserList(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYuser/getUserList',
    method: 'post',
    // params: query
    data
  })
}

// 根据角色ID查询部门树结构
export function roleDeptTreeselect(roleId) {
  return request({
    url: '/api/v1/roleDeptTreeselect/' + roleId,
    method: 'get'
  })
}

// 新增部门
export function addDept(data) {
  return request({
    url: '/api/v1/dept',
    method: 'post',
    data: data
  })
}

// 修改部门
export function updateDept(data) {
  return request({
    url: '/api/v1/dept',
    method: 'put',
    data: data
  })
}

// 删除部门
// export function delDept(deptId) {
//   return request({
//     url: '/api/v1/dept/' + deptId,
//     method: 'delete'
//   })
// }
export function delDept(query) {
  const data = mergeParams(query)
  return newRequest({
    url: '/SYS/SYDept/doDelete',
    method: 'delete',
    // params: query
    data
  })
}
